package com.basker.pisces.domain.constant;

import com.basker.pisces.domain.entity.meta.BeanEntity;
import com.basker.pisces.service.exception.IObjectErrorsWrapper.ObjectError;

public class DomainConstants {

    /**
     * 命令常量
     *
     * @author hangwen
     */
    public static class Command {

        /**
         * {@link BeanEntity}默认的保存命令的名称
         */
        public static final String DEFAULT_SAVE_COMMAND_NAME = "$SaveCommand";

        /**
         * {@link BeanEntity}默认的删除命令的名称
         */
        public static final String DEFAULT_DELETE_COMMAND_NAME = "$DeleteCommand";
    }

    /**
     * {@link ObjectError#getErrorCode()}对应的常量
     *
     * @author hangwen
     */
    public static class ObjectErrorCode {

        /**
         * 违反必填属性约束
         */
        public static final String REQUIRED_VIOLATION = "-200000";

        /**
         * 违反唯一属性约束(数据库已存在)
         */
        public static final String UNIQUE_EXIST_VIOLATION = "-200001";

        /**
         * 违反唯一属性并发约束
         */
        public static final String UNIQUE_CONCURRENT_VIOLATION = "-200002";

        /**
         * 命令未获取对象的访问锁
         */
        public static final String OBJECT_COMMAND_LOCK_FAILURE = "-200003";

        /**
         * 违反唯一属性重复唯一值约束(同一批次里，有相同数据)
         */
        public static final String UNIQUE_MULTIPLE_VIOLATION = "-200004";

        /**
         * 违反属性长度约束
         */
        public static final String MAXLENGTH_VIOLATION = "-200010";

        /**
         * 违反正则表达式约束
         */
        public static final String REGEX_VIOLATION = "-200011";

        /**
         * 无效枚举值
         */
        public static final String ENUM_INVALID = "-200020";

        /**
         * 无效状态值
         */
        public static final String STATUS_INVALID = "-200030";

        /**
         * 违反合法状态约束
         */
        public static final String VALID_STATUS_VIOLATION = "-200031";

        /**
         * 无效的日期值
         */
        public static final String DATE_INVALID = "-200040";

        /**
         * 无效的业务对象代码
         */
        public static final String OBJECT_CODE_INVALID = "-200050";

        /**
         * 无效的时间长度值
         */
        public static final String DURATION_INVALID = "-200060";

        /**
         * 无效的邮箱
         */
        public static final String EMAIL_INVALID = "-200070";

        /**
         * 无效的身份证号
         */
        public static final String ID_CARD_NO_INVALID = "-200080";

    }

    /**
     * 数据状态常量
     *
     * @author hangwen
     */
    public static class DataStatus {

        /**
         * 删除状态
         */
        public static final Integer DELETE = -9999;

        /**
         * 初始状态
         */
        public static final Integer INITIAL = 0;

        /**
         * 启用状态
         */
        public static final Integer ENABLE = 1;

        /**
         * 不可用状态
         */
        public static final Integer DISABLE = 2;
    }

    /**
     * Service的错误码常量
     *
     * @author hangwen
     */
    public static class StatusCode {
        /**
         * 非法对象的状态码(没有通过数据校验)
         */
        public static final Integer INVALID_OBJECT_VIOLATION = -3001;

        /**
         * 非法属性的状态码
         */
        public static final Integer INVALID_PROPERTY_VIOLATION = -3002;
    }

    /**
     * 验证器常量
     *
     * @author hangwen
     */
    public static class Validation {
        /**
         * {@link BeanEntity}默认的Id唯一校验器
         */
        public static final String ID_UNIQUE_VALIDATION = "$IdUniqueValidation";
    }
}
